/************************************************************************************************
 * test examples of 100 interesting program in C
 * test 045.c
 * egypt number for any proper fraction
 ***********************************************************************************************/

#include <stdio.h>
#include <string.h>

/*
 *
 */

int main()
{
	int a = 0, b = 0, c = 0;
	printf("Plz input a proper fraction: ");
	scanf("%d/%d", &a, &b);

	printf("%d/%d = ", a, b);

	while (1)
	{
		if (b%a != 0)
			c = b/a + 1;
		else
		{
			c = b/a;
			a = 1;
		}
		if (a == 1)
		{
			printf("1/%d\n", c);
			break;
		}
		else
			printf("1/%d + ", c);
		a = a*c - b;
		b = b*c;
	}
}

